package gui;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import main.Input;


public class MainUI extends JFrame
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTabbedPane tabbedPane;
	private UISale sale;
	private UIPresentMovie presentMovie;
	private UISearch search;
	private UIAdmin admin;
	
	private static MainUI instance;
	
	private MainUI()
	{
		tabbedPane = new JTabbedPane();
		initializeTabs(); 
		tabbedPane.addTab(presentMovie.getName(), presentMovie);
		tabbedPane.addTab(sale.getName(), sale);
		tabbedPane.addTab(search.getName(), search);
		tabbedPane.addTab(admin.getName(), admin);
		getContentPane().add(tabbedPane);
		
		//add input listener
		Input.initializeInstance(tabbedPane);
		tabbedPane.addKeyListener(Input.getInstance());
		
		//TODO window size is set here!
		setBounds(100, 30, 800, 800);
		setExtendedState(MAXIMIZED_BOTH);
	}
	
	public static MainUI getInstace()
	{
		if(instance == null) {
			instance = new MainUI();
		}
		
		return instance;
	}
		
	
	private void initializeTabs()
	{
		presentMovie = new UIPresentMovie();
		sale = new UISale();
		search = new UISearch();
		admin = new UIAdmin();
	}
}
